/**
 * 提取数据中某个分类的值，
 * @param data 数据源
 * @param type 提取分类的key
 * @returns 返回数组类型数据
 */
export const extractType = (data, type) => {
  const typeArray: any = []
  data.forEach(item => {
    if (!typeArray.includes(item[type])) {
      typeArray.push(item[type])
    }
  })
  return typeArray
}

/** 获取地图json数据 */
export const getJsonMap = async () => {
  const jsonFiles = import.meta.glob('@/components/EChart/src/options/series/map/data/**/*.json')
  const mapJsonList: any = {}
  for (const path in jsonFiles) {
    const module: any = await jsonFiles[path]()
    const keyArr = path.split('/')
    const key = keyArr[keyArr.length - 1].split('.')[0]
    mapJsonList[key] = module.default
  }
  return mapJsonList
}
